<cfcomponent extends="assets.csac.com.Base">

	<cffunction name="get" access="public" output="false" returntype="assets.csac.com.bo.Tracking">
		<cfargument name="Tracking_ID" type="string" required="true" />
		<cfscript>
			if (arguments.Tracking_ID gt 0) {
				local.loadArgs = {};
				local.loadArgs.obj = new assets.csac.com.bo.Tracking();
				StructAppend(local.loadArgs, QueryToStruct(read(argumentCollection = arguments))[1]);
				local.loadArgs.Deleted = 0;
				return load(argumentCollection = local.loadArgs);
			} else {
				return new assets.csac.com.bo.Tracking();
			}
		</cfscript>
	</cffunction>

	<cffunction name="load" access="public" output="false" returntype="assets.csac.com.bo.Tracking">
		<cfargument name="obj" type="assets.csac.com.bo.Tracking" required="true" />
		<cfscript>
			local.obj = arguments.obj;
			if (IsDefined("arguments.Tracking_ID")) {
				local.obj.setTracking_ID(arguments.Tracking_ID);
			}
			if (IsDefined("arguments.Order_ID")) {
				local.obj.setOrder_ID(arguments.Order_ID);
			}
			if (IsDefined("arguments.Order_Product_IDs")) {
				local.obj.setOrder_Product_IDs(arguments.Order_Product_IDs);
			}
			if (IsDefined("arguments.Deleted")) {
				local.obj.setDeleted(arguments.Deleted); 
			}
			if (IsDefined("arguments.Tracking_Code")) {                             
				local.obj.setTracking_Code(arguments.Tracking_Code);
			}
			if (IsDefined("arguments.Date_Created")) {
				local.obj.setDate_Created(arguments.Date_Created);
			}			
			return local.obj;
		</cfscript>
	</cffunction>

	<cffunction name="read" access="public" output="false" returntype="any">
		<cfargument name="Tracking_ID" required="false" default="" />
		<cfargument name="Order_ID" required="false" default="" />
		<cfargument name="Order_Product_IDs" required="false" default="" />
		<cfargument name="Deleted" required="false" default="0" />
		<cfargument name="Tracking_Code" required="false" default="" />
		<cfargument name="Date_Created" required="false" default="" />
		<cfargument name="trackingIDs" required="false" default="" />
		<cfargument name="trackingCodes" required="false" default="" />

		<cfset var recs = "">
		<cfstoredproc datasource="#getDatasource()#" procedure="readTracking">
			<cfprocparam value="#arguments.Tracking_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Tracking_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Order_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Order_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Order_Product_IDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Order_Product_IDs)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Deleted#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Deleted)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Tracking_Code#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Tracking_Code)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Date_Created#" cfsqltype="CF_SQL_TIMESTAMP" null="#IIf(Len(Trim(arguments.Date_Created)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.trackingIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.trackingIDs)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.trackingCodes#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.trackingCodes)) eq 0, true, false)#" />
			<cfprocresult name="recs" />
		</cfstoredproc>
		<cfreturn recs />
	</cffunction>

	<cffunction name="save" access="public" output="false" returntype="any">
		<cfargument name="tracking" required="true" type="assets.csac.com.bo.Tracking" />

		<cfstoredproc datasource="#getDatasource()#" procedure="saveTracking">
			<cfprocparam value="#tracking.getTracking_ID()#" cfsqltype="CF_SQL_INTEGER" variable="id" type="inout" null="false" />
			<cfprocparam value="#tracking.getOrder_ID()#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="#tracking.getOrder_Product_IDs()#" cfsqltype="CF_SQL_VARCHAR" null="false" />
			<cfprocparam value="#tracking.getDeleted()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#tracking.getTracking_Code()#" cfsqltype="CF_SQL_VARCHAR" null="false" />
		</cfstoredproc>
		<cfreturn id />
	</cffunction>

	<cffunction name="destroy" access="public" output="false" returntype="any">
		<cfargument name="Tracking_ID" required="true" />

		<cfstoredproc datasource="#getDatasource()#" procedure="destroyTracking">
			<cfprocparam value="#arguments.Tracking_ID#" cfsqltype="CF_SQL_INTEGER" null="false" />
		</cfstoredproc>
		<cfreturn true />
	</cffunction>

</cfcomponent>

